package com.xhh.nphm.system.service.impl;

import com.xhh.nphm.system.domain.TtelBlackEty;
import com.xhh.nphm.system.domain.TtelRedEty;
import com.xhh.nphm.system.mapper.TelBlackDao;
import com.xhh.nphm.system.mapper.TelNameListDao;
import com.xhh.nphm.system.mapper.TelRedDao;
import com.xhh.nphm.system.service.ITelNameListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TelNameListServiceImpl implements ITelNameListService {
    @Autowired
    private TelNameListDao telNameListDao;
    @Autowired
    private TelRedDao telRedDao;
    @Autowired
    private TelBlackDao telBlackDao;

    @Override
    public List<TtelBlackEty> listBlack(TtelBlackEty ttelBlackEty) {
        return telNameListDao.listBlack(ttelBlackEty);
    }

    @Override
    public List<TtelRedEty> listRed(TtelRedEty ttelRedEty) {
        return telNameListDao.listRed(ttelRedEty);
    }

    @Transactional(transactionManager = "ds1TransactionManager", rollbackFor = Exception.class)
    @Override
    public int saveBlack(TtelBlackEty ttelBlackEty) {
        return telNameListDao.insertBlack(ttelBlackEty);
    }

    @Transactional(transactionManager = "ds1TransactionManager", rollbackFor = Exception.class)
    @Override
    public int saveRed(TtelRedEty ttelRedEty) {
        return telNameListDao.insertRed(ttelRedEty);
    }

    @Transactional(transactionManager = "ds1TransactionManager", rollbackFor = Exception.class)
    @Override
    public int deleteBlack(Integer... ids) {
        return telNameListDao.deleteBlackBatchIds(ids);
    }

    @Transactional(transactionManager = "ds1TransactionManager", rollbackFor = Exception.class)
    @Override
    public int deleteRed(Integer... ids) {
        return telNameListDao.deleteRedBatchIds(ids);
    }

    @Override
    public TtelBlackEty selectBlack(Integer id) {
        return telBlackDao.selectById(id);
    }

    @Override
    public TtelRedEty selectRed(Integer id) {
        return telRedDao.selectById(id);
    }

    @Transactional(transactionManager = "ds1TransactionManager", rollbackFor = Exception.class)
    @Override
    public int editRed(TtelRedEty ttelRedEty) {
        return telNameListDao.editRed(ttelRedEty);
    }
    @Transactional(transactionManager = "ds1TransactionManager", rollbackFor = Exception.class)
    @Override
    public int editBlack(TtelBlackEty ttelBlackEty) {
        return telNameListDao.editBlack(ttelBlackEty);
    }

}
